package com.xiaomi.shop.controller;

import com.xiaomi.shop.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @ClassName 陈欣月
 * @Descripttion TODO
 * @Author cxy
 * @Date 2021/10/13 17:05
 * @Version 1.0
 **/
@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;
    /**
     * 登录
      * @param name
     * @param pwd
     * @param model
     * @return
     */
    @RequestMapping("/login.action")
    public String login(String name, String pwd, Model model){
        //调用登录的方法
        String str= adminService.login(name,pwd);
        if("ok".equals(str)){
            //登录成功了
            model.addAttribute("adminName",name);
            return "main";
        }else {
            model.addAttribute("errmsg","您的用户名或密码错误");
            return "login";
        }

    }
}
